// 初始化 mongodb 操作
const { MongoClient } = require("mongodb");

// 从配置文件中获取账号和密码
const { username, password, ip, port, name } = global.config.db;

// 构建包含账号和密码的连接 URI
const uri = `mongodb://${username}:${password}@${ip}:${port}/${name}`;

const client = new MongoClient(uri, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

module.exports = client;
